-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate unique id for device peripherals #857
base: master
Are you sure you want to change the base?
Conversation
f559b42
to
ed21f8f
Compare
Not a complaint about your solution - AFAIKT it should work - but I wonder: The comment above
If you only get errors with LTO enabled, is the purpose stated in that comment reached at all? If it doesn't work anyway, we could as well remove the |
#[no_mangle]
attribute for device peripherals
That's certainly a bug though? The idea is that, if it works, you should not be able to easily claim two mutable references using two different versions of the library. I think the no_mangle should stay and a name corresponding to the device name to be used, its still useful, and also useful even with non-mut static (in the future 2024 edition). |
I'm not sure if this is the intended way to use |
To me it seems like a fair way to use it, but maybe we could (ab)use |
no_mangle makes a symbol visible (unconditionally) under that exact name. Why ThinLTO allows this is very strange |
This reverts commit e927cf1.
#[no_mangle]
attribute for device peripherals
rust-lang/rust#28179 may be relevant here. Money quote: "I'd argue that having multiply-defined #[no_mangle] symbols is, in essence, undefined behavior (in the sense that nobody defined it)" |
We discussed this a bit in the meeting today.
|
Just as a data point: I did some quick tests using rp2040-pac. Compiling a program calling
This is the same for both release and debug builds. |
Thanks, it's useful to know it's only a problem on thin LTO. Perhaps another good reason to plan to move away from owned singletons given out like this. |
Related: rust-embedded/wg#467 |
Hi! I encoutered errors when compiling project with multiple devices used and lto enabled.
The problem is similar to this issue with generated variable
DEVICE_PERIPHERALS
.This PR solves the problem by generating unique name based on the device name
removing.#[no_mangle]
attribute